// Learn cc.Class:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        shotSpeed: {
            default: 50,
            type: cc.Integer,
            displayName: "子弹射击速度(px)",
        },
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        var r = cc.misc.degreesToRadians(this.node.rotation);
        var v = cc.v2(0,1).rotate(-r);
        this.getComponent(cc.RigidBody).linearVelocity = v.mul(this.shotSpeed);
    },

    // update (dt) {},

    onBeginContact(){
        this.node.destroy();
    }
});
